package com.auto.survey.util.monitoring.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.auto.survey.util.monitoring.entity.RearIntersectionCalculationResult

@Dao
interface MonitoringStationCalculationResultDao {

    // 插入单个结果
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(result: RearIntersectionCalculationResult): Long

    // 插入多个结果
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAll(results: List<RearIntersectionCalculationResult>): List<Long>

    // 根据ID查询结果
    @Query("SELECT * FROM MonitoringStationCalculationResult WHERE id = :id")
    suspend fun getById(id: Long): RearIntersectionCalculationResult?

    // 查询所有结果
    @Query("SELECT * FROM MonitoringStationCalculationResult")
    suspend fun getAll(): List<RearIntersectionCalculationResult>

    // 更新结果
    @Update
    suspend fun update(result: RearIntersectionCalculationResult): Int

    // 删除结果
    @Delete
    suspend fun delete(result: RearIntersectionCalculationResult): Int

    // 根据ID删除结果
    @Query("DELETE FROM MonitoringStationCalculationResult WHERE id = :id")
    suspend fun deleteById(id: Long): Int
}